<!DOCTYPE html>
<html lang="zh-CN">
<head><meta charset="UTF-8"><title>支付通道管理</title>
<link rel="stylesheet" href="/layui/css/layui.css"><script src="/static/js/jquery.min.js"></script><script src="/layui/layui.js"></script>
<style>body{background:#f5f5f5;padding:20px;}</style></head>
<body>
<div class="layui-card"><div class="layui-card-header">支付通道列表 <a href="/admin/pay/add" class="layui-btn layui-btn-sm layui-btn-normal" style="float:right;">添加通道</a></div>
<div class="layui-card-body"><table class="layui-table" lay-size="sm"><thead><tr><th>ID</th><th>名称</th><th>版本</th><th>网关地址</th><th>商户ID</th><th>支付方式</th><th>排序</th><th>状态</th><th>操作</th></tr></thead>
<tbody><?php foreach($list as $item): ?><tr><td><?= $item['id'] ?></td><td><?= $item['name'] ?></td><td><?= $item['version'] ?></td><td style="max-width:200px;word-break:break-all;"><?= htmlspecialchars($item['api_url']) ?></td><td><?= $item['merchant_id'] ?></td><td><?= $item['pay_type'] ?></td><td><?= $item['sort'] ?></td><td><?= $item['status']?'<span style="color:green">开启</span>':'<span style="color:red">关闭</span>' ?></td><td><a href="/admin/pay/edit?id=<?=$item['id']?>" class="layui-btn layui-btn-xs layui-btn-normal">编辑</a> <button class="layui-btn layui-btn-xs layui-btn-warm" onclick="toggleStatus(<?=$item['id']?>)"><?=$item['status']?'关闭':'开启'?></button> <button class="layui-btn layui-btn-xs layui-btn-danger" onclick="del(<?=$item['id']?>)">删除</button></td></tr><?php endforeach; ?><?php if(empty($list)):?><tr><td colspan="9" style="text-align:center;color:#999;">暂无数据</td></tr><?php endif;?></tbody></table><div id="page"></div></div></div>
<script>
var total=<?=$total?>,page=<?=$page?>,pageSize=<?=$pageSize?>;
layui.use('laypage',function(){var p=layui.laypage;if(total>pageSize){p.render({elem:'page',count:total,limit:pageSize,curr:page,jump:function(o,f){if(!f) location.href='/admin/pay/index?page='+o.curr;}});}});
function toggleStatus(id){$.post('/admin/pay/toggleStatus',{id:id},function(res){layer.msg(res.msg);setTimeout(function(){location.reload();},1000);});}
function del(id){layer.confirm('确认删除？',function(){$.post('/admin/pay/delete',{id:id},function(res){layer.msg(res.msg,{icon:res.code===0?1:2});if(res.code===0) setTimeout(function(){location.reload();},1000);});});}
</script></body></html>